<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>JSX</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      header{
        height: 100px;
        background: #fee;
      }
      main{
        height: 400px;
        background: #efe;
      }
      footer{
        height: 100px;
        background: #eef;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //声明一个类
      class Header extends React.Component{
        //声明一个方法 render
        render(){
          //返回虚拟 DOM 对象
          return <header></header>;
        }
      }

      class Content extends React.Component{
        render(){
          return <main></main>;
        }
      }

      class Footer extends React.Component{
        render(){
          return <footer></footer>;
        }
      }

      class App extends React.Component{
        //名字一定要写成 render
        render(){
          //声明虚拟 dom 对象  Header 内部在渲染的时候, 会根据组件标签找同名的类, 实例化对象, 再然后使用实例化对象调用 render 方法获得虚拟 DOM 对象,再进行渲染
          return <div>
                  <Header></Header>
                  <Content />
                  <Footer />
                </div>
        }
      }
      
      ReactDOM.render(<App />, document.querySelector('#root'))
    </script>
  </body>
</html>
